package com.wf.quartz;

import com.wf.constant.RedisConstant;
import com.wf.service.ContractInfoService;
import com.wf.utils.RedisUtil;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @author mpk
 * @since 2024/9/10 18:57:37
 */
@Component
public class AllViewQuartz  extends QuartzJobBean {

    @Autowired
    private ContractInfoService contractInfoService;

    @Autowired
    RedisUtil redisUtil;
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {



        contractInfoService.updateAllView();
        //清除redis中的浏览量
        Set<String> keys = redisUtil.keys(RedisConstant.APARTMENT_HOUSE_VIEW_COUNT + "*");
        for (String key : keys) {
            redisUtil.del(key);
        }


    }
}
